//
//  SettingView.swift
//  Crypto
//
//  Created by DaleGuo on 2023/9/26.
//

import SwiftUI

struct SettingView: View {
    
    let coingeckoURL = URL(string: "https://www.coingecko.com")
    let myNoteURL = URL(string: "https://www.yuque.com/dalee-ieu8g/gzsir5/zyga2ld1208q6v49")
    
    var body: some View {
        NavigationStack {
            List {
                introView
                coinGecko
            }
            .listStyle(.grouped) // 结合Section一同产生效果
            .navigationTitle("Settings")
            .toolbar {
                ToolbarItem(placement: .topBarLeading) {
                    XMarkButton()
                }
            }
        }
    }
}

#Preview {
    SettingView()
}

extension SettingView {
    private var introView : some View {
        Section {
            VStack(alignment: .leading) {
                Image("logo")
                    .resizable()
                    .frame(width: 100,height: 100)
                    .clipShape(RoundedRectangle(cornerRadius: 20))
                Text("This app was a cool thing to collect your coins!")
                    .font(.callout)
                    .fontWeight(.medium)
                    .foregroundStyle(Color.theme.accent)
            }
            .padding(.vertical)
            Link("My Notes about SwiftUI",destination: myNoteURL!)
                .tint(Color.blue)
            
        } header: {
            Text("introduction")
        }


    }
    
    private var coinGecko : some View {
        Section {
            VStack(alignment: .leading) {
                Image("coingecko")
                    .resizable()
                    .scaledToFit()
                    .frame(height: 100)
                    
                    
                    
//                    .frame(height: 100)
//                    .clipShape(RoundedRectangle(cornerRadius: 20))
                Text("coingecko-coingecko-coingecko-coingecko-coingecko!!thanks their APIs")
                    .font(.callout)
                    .fontWeight(.medium)
                    .foregroundStyle(Color.theme.accent)
            }
            .padding(.vertical)
            Link("Website 🥰",destination: coingeckoURL!)
                .tint(Color.blue)
            
        } header: {
            Text("coingecko")
        }


    }
}



